package net.heartbeat.heartbeats.fixed;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import net.heartbeat.HeartbeatTransferer;

public class FixedHeartbeatTransferer implements HeartbeatTransferer<FixedHeartbeat> {
	@Override
	public void send(FixedHeartbeat heartbeat, OutputStream raw) throws IOException {
		DataOutputStream output = new DataOutputStream(raw);
		output.writeUTF(heartbeat.content);
		output.flush();
	}

	@Override
	public FixedHeartbeat receive(InputStream raw) throws IOException {
		DataInputStream input = new DataInputStream(raw);
		String content = input.readUTF();
		return new FixedHeartbeat(content);
	}

}
